use crate::config;
use crate::controller::index;
use actix_web::fs::NamedFile;
use actix_web::fs::StaticFiles;
use actix_web::http::Method;
use actix_web::App;

pub fn static_route(app: App) -> App {
    let cfg = config::get_global_config();
    app.handler("/static", {
        StaticFiles::new(cfg.path.static_path.clone())
            .unwrap()
            .show_files_listing()
    })
    .resource("/favicon.ico", |r| {
        r.method(Method::GET).f(|_| {
            let cfg = config::get_global_config();
            NamedFile::open(cfg.path.favicon_path.clone()).unwrap()
        })
    })
}

pub fn business_route(app: App) -> App {
    app.resource("/", |r| r.method(Method::GET).f(index::index))
}

